package com.example.springboot.Aop.Aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Aspect
@Component
public class AspectTest_02 {


    @Around("execution(* com.example.springboot.Aop.Controller.AopTest02.*(..))")
    public void aroundAdvice(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("环绕通知开始");

        System.out.println(Arrays.stream(proceedingJoinPoint.getArgs()).toArray().toString());

        Object obj = proceedingJoinPoint.proceed();

        System.out.println("/t"+obj.toString());


        System.out.println("环绕通知结束");
    }

    @Before("execution(* com.example.springboot.Aop.Controller.AopTest02.*(..))")
    public void beforeAdvice(){
        System.out.println("前置通知");
    }

    @AfterReturning("execution(* com.example.springboot.Aop.Controller.AopTest02.*(..))")
    public void afterReturningAdvice(){
        System.out.println("后置通知");
    }

    @AfterThrowing("execution(* com.example.springboot.Aop.Controller.AopTest02.*(..))")
    public void afterThrowingAdvice(){
        System.out.println("异常通知");
    }

    @After("execution(* com.example.springboot.Aop.Controller.AopTest02.*(..))")
    public void afterAdvice(){
        System.out.println("最终通知");
    }


}
